#include "AtomicTest1.h"
#include<thread>
#include<atomic>
#include<iostream>

using namespace com::example::testone::thread::atomic;
using namespace std;


com::example::testone::thread::atomic::AtomicTest1::AtomicTest1()
{
    //ctor
}

com::example::testone::thread::atomic::AtomicTest1::~AtomicTest1()
{
    //dtor
}

void com::example::testone::thread::atomic::AtomicTest1::run1(){
    std::thread::id t_id = std::this_thread::get_id();
    cout << "t_id = " << t_id << endl;
    for(int i = 0; i < 100000; i++){
        this->atomic_a++;
        this->b++;
    }

}

void com::example::testone::thread::atomic::AtomicTest1::test1(){

    AtomicTest1 at1;
    std::thread t1(&AtomicTest1::run1, &at1);
    std::thread t2(&AtomicTest1::run1, &at1);

    t1.join();
    t2.join();
    cout << "atomic_a = " << at1.atomic_a << endl;
    cout << "b = " << at1.b << endl;
}

